package com.info.zhiduoduo.admin.controller;

import com.info.zhiduoduo.admin.model.formbean.complaint.AddCompliantFormBean;
import com.info.zhiduoduo.admin.model.formbean.complaint.ComplaintListFormBean;
import com.info.zhiduoduo.admin.model.formbean.complaint.ReplyComplaintFormBean;
import com.info.zhiduoduo.admin.service.ComplaintService;
import com.info.zhiduoduo.common.annotation.LogEntity;
import com.info.zhiduoduo.common.annotation.LogParameter;
import com.info.zhiduoduo.common.annotation.ZddLog;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.constants.system.ZddLogType;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import com.info.zhiduoduo.repository.dto.complaint.ComplaintDto;

import com.info.zhiduoduo.repository.entity.complaint.Complaint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/complaint")
@Api(tags = "用户投诉")
public class ComplaintController {

	@Autowired
	ComplaintService complaintService;


	@ApiOperation("获取用户投诉列表,支持分页")
	@PostMapping("/complaintList")
	public SmartResult<ComplaintDto> getComplaintList(@RequestBody BaseSimpleFormBean<ComplaintListFormBean> formBean) {
		return complaintService.getComplaintList(formBean);
	}

	@ZddLog(name = "新增或修改用户投诉")
	@ApiOperation("新增或修改用户投诉")
	@PostMapping("/addOrUpdateComplaint")
	public SmartResult addOrUpdateComplaint(@RequestBody BaseSimpleFormBean<AddCompliantFormBean> formBean){
		return complaintService.addOrUpdateComplaint(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE,name = "回复投诉",entities = @LogEntity(entity = Complaint.class,parameters =
	@LogParameter(fields = "id",parameters = "formBean.reqdata.id")))
	@ApiOperation("回复投诉")
	@PostMapping("/replyComplaint")
	public SmartResult replyComplaint(@RequestBody BaseSimpleFormBean<ReplyComplaintFormBean> formBean) {
		return complaintService.replyComplaint(formBean);
	}

	@ApiOperation(value = "获取投诉详情", notes = "reqdata传投诉id")
	@PostMapping("/detail")
	public SmartResult<ComplaintDto> getDetail(@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return complaintService.getDetail(formBean);
	}
}
